package com.yoyo.series;

import java.io.File;

import android.app.Application;
import android.content.Context;

import com.nostra13.universalimageloader.cache.disc.impl.FileCountLimitedDiscCache;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
import com.yoyo.series.data.Repository;
import com.yoyo.series.utilites.FileUtilities;

public class MyApplication extends Application {

    public MyApplication()
    {
    }

    public static void closeDB()
    {
        if(repository != null)
        {
            repository.closeDB();
            repository = null;
        }
    }

    public static void initImageLoader(Context context)
    {
        File file = new File(FileUtilities.getImageFolder());
        com.nostra13.universalimageloader.core.ImageLoaderConfiguration imageloaderconfiguration = (new com.nostra13.universalimageloader.core.ImageLoaderConfiguration.Builder(context)).threadPriority(3).denyCacheImageMultipleSizesInMemory().discCache(new FileCountLimitedDiscCache(file, 5000)).discCacheFileNameGenerator(new Md5FileNameGenerator()).tasksProcessingOrder(QueueProcessingType.LIFO).build();
        ImageLoader.getInstance().init(imageloaderconfiguration);
    }

    public static void initializeDB()
    {
        repository = Repository.getInstance();
    }

    /**
     * @deprecated Method setFlag is deprecated
     */

    public static void setFlag(int i)
    {
//        com/stayit/series/MyApplication;
//        JVM INSTR monitorenter ;
//        mAppState = i;
//        com/stayit/series/MyApplication;
//        JVM INSTR monitorexit ;
//        return;
//        Exception exception;
//        exception;
//        throw exception;
    }

    public void onCreate()
    {
        super.onCreate();
//        gAppContext = (MyApplication)getApplicationContext();
//        Trace.DEBUG = Boolean.valueOf(Utils.trans(0x7f040013)).booleanValue();
//        initImageLoader(getApplicationContext());
    }

    public static MyApplication gAppContext;
    public static int mAppState = -1;
    public static Repository repository;
}
